function RequestUtils() {
};

RequestUtils.prototype._read = function(name, func, condition, page, size, order, queue, callBackFunc, options) {
  var php = (options && options.php) ? options.php : '{{$smarty.const.READ|escape:'javascript'}}';
  var request = new Request(this._parseRead, { method: 'POST', context: this, params: { callBackFunc: callBackFunc, options: options } });
  request._request(php + '?name=' + name, ((func) ? '&f=' + func : '') + ((condition) ? '&c=' + condition : '') + ((page) ? '&p=' + page : '') + ((size) ? '&s=' + size : '') + ((order) ? '&o=' + order : '') + ((queue) ? '&q=' + queue : ''));
};

RequestUtils.prototype._parseRead = function(result, params) {
  if (params.callBackFunc) {
    params.callBackFunc(result, params);
  }
};

RequestUtils.prototype._write = function(name, objectsToAddOrUpdate, objectsToRemove, callBackFunc, options) {
  var php = (options && options.php) ? options.php : '{{$smarty.const.WRITE|escape:'javascript'}}';
  var request = new Request(this._parseWrite, { method: 'POST', context: this, params: { callBackFunc: callBackFunc, options: options } });
  request._request(php + '?name=' + name, 'obj=' + JSON.stringify(objectsToAddOrUpdate) + '&r=' + JSON.stringify(objectsToRemove));
};

RequestUtils.prototype._parseWrite = function(result, params) {
  if (params.callBackFunc) {
    params.callBackFunc(result, params);
  }
};

RequestUtils.prototype._custom = function(action, args, callBackFunc, options) {
  var php = (options && options.php) ? options.php : '{{$smarty.const.CUSTOM|escape:'javascript'}}';
  var request = new Request(this._parseCustom, { method: 'POST', context: this, params: { callBackFunc: callBackFunc, options: options } });
  request._request(php + '?action=' + action, ((args) ? args : ''));
};

RequestUtils.prototype._parseCustom = function(result, params) {
  if (params.callBackFunc) {
    params.callBackFunc(result, params);
  }
};
